<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>小学教师智能评语生成系统</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        :root {
            --primary-color: #2A5CAA;
            --secondary-color: #FFEFD5;
            --accent-color: #4CAF50;
            --text-color: #333;
            --light-gray: #f5f5f5;
            --shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
            --card-radius: 16px;
            --transition: all 0.3s ease;
        }
        
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
            line-height: 1.6;
            color: var(--text-color);
            background: linear-gradient(135deg, #f0f7ff 0%, #e6f3ff 100%);
            padding: 20px;
            min-height: 100vh;
        }
        
        .container {
            max-width: 1200px;
            margin: 0 auto;
        }
        
        header {
            text-align: center;
            margin-bottom: 30px;
            padding: 25px;
            background: linear-gradient(135deg, var(--primary-color), #1a3f7a);
            color: white;
            border-radius: var(--card-radius);
            box-shadow: var(--shadow);
            position: relative;
            overflow: hidden;
        }
        
        header::before {
            content: "";
            position: absolute;
            top: -50px;
            right: -50px;
            width: 150px;
            height: 150px;
            background: rgba(255, 255, 255, 0.1);
            border-radius: 50%;
        }
        
        header::after {
            content: "";
            position: absolute;
            bottom: -80px;
            left: -30px;
            width: 200px;
            height: 200px;
            background: rgba(255, 255, 255, 0.07);
            border-radius: 50%;
        }
        
        h1 {
            font-size: 2.2rem;
            margin-bottom: 10px;
            position: relative;
            z-index: 2;
        }
        
        .subtitle {
            font-size: 1.1rem;
            opacity: 0.9;
            max-width: 700px;
            margin: 0 auto;
            position: relative;
            z-index: 2;
        }
        
        .dimension-selectors {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 25px;
            margin-bottom: 40px;
        }
        
        .dimension-card {
            background: white;
            border-radius: var(--card-radius);
            padding: 25px;
            box-shadow: var(--shadow);
            transition: var(--transition);
            position: relative;
            overflow: hidden;
            border: 1px solid rgba(42, 92, 170, 0.1);
        }
        
        .dimension-card:hover {
            transform: translateY(-8px);
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
        }
        
        .dimension-title {
            color: var(--primary-color);
            font-size: 1.3rem;
            margin-bottom: 18px;
            padding-bottom: 12px;
            border-bottom: 2px solid var(--secondary-color);
            display: flex;
            align-items: center;
            position: relative;
        }
        
        .dimension-title i {
            margin-right: 10px;
            font-size: 1.5rem;
            width: 40px;
            height: 40px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: rgba(42, 92, 170, 0.1);
            border-radius: 50%;
        }
        
        .options-container {
            display: flex;
            flex-wrap: wrap;
            gap: 12px;
        }
        
        .option-btn {
            flex: 1;
            min-width: 80px;
            padding: 12px 15px;
            background: var(--light-gray);
            border: none;
            border-radius: 8px;
            cursor: pointer;
            font-size: 0.95rem;
            transition: var(--transition);
            text-align: center;
            position: relative;
            overflow: hidden;
        }
        
        .option-btn::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 3px;
            background: var(--primary-color);
            transform: scaleX(0);
            transition: var(--transition);
            transform-origin: left;
        }
        
        .option-btn:hover {
            background: #e9e9e9;
            transform: translateY(-3px);
        }
        
        .option-btn.selected {
            background: var(--secondary-color);
            font-weight: 600;
            box-shadow: 0 4px 8px rgba(42, 92, 170, 0.2);
        }
        
        .option-btn.selected::after {
            transform: scaleX(1);
        }
        
        .comment-section {
            background: white;
            border-radius: var(--card-radius);
            padding: 30px;
            box-shadow: var(--shadow);
            margin-bottom: 40px;
            border: 1px solid rgba(42, 92, 170, 0.1);
        }
        
        .comment-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
            flex-wrap: wrap;
            gap: 15px;
        }
        
        .word-count {
            font-size: 0.9rem;
            color: #666;
            background: rgba(42, 92, 170, 0.05);
            padding: 8px 15px;
            border-radius: 30px;
            display: flex;
            align-items: center;
            gap: 8px;
        }
        
        .word-count .highlight {
            color: var(--primary-color);
            font-weight: bold;
            font-size: 1.1rem;
        }
        
        .generate-btn {
            background: linear-gradient(135deg, var(--primary-color), #3a7bd5);
            color: white;
            border: none;
            padding: 12px 25px;
            border-radius: 8px;
            cursor: pointer;
            font-size: 1rem;
            font-weight: 600;
            transition: var(--transition);
            display: flex;
            align-items: center;
            gap: 8px;
            box-shadow: 0 4px 12px rgba(42, 92, 170, 0.3);
        }
        
        .generate-btn:hover {
            background: linear-gradient(135deg, #1a3f7a, #2a5caa);
            transform: translateY(-2px);
            box-shadow: 0 6px 15px rgba(42, 92, 170, 0.4);
        }
        
        .generate-btn:active {
            transform: translateY(1px);
        }
        
        .comment-display {
            min-height: 150px;
            border: 1px solid #eee;
            border-radius: 8px;
            padding: 20px;
            background: rgba(255, 239, 213, 0.2);
            font-size: 1.1rem;
            line-height: 1.8;
            margin-bottom: 20px;
            position: relative;
            transition: var(--transition);
        }
        
        .comment-display:focus {
            outline: 2px solid var(--primary-color);
        }
        
        .placeholder-text {
            color: #999;
            font-style: italic;
            text-align: center;
            padding: 20px;
        }
        
        .copy-section {
            display: flex;
            justify-content: flex-end;
        }
        
        .copy-btn {
            background: #5a6268;
            color: white;
            border: none;
            padding: 10px 25px;
            border-radius: 8px;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 8px;
            transition: var(--transition);
        }
        
        .copy-btn:hover {
            background: #42484d;
            transform: translateY(-2px);
        }
        
        .copy-btn.copied {
            background: var(--accent-color);
        }
        
        .loading {
            display: none;
            text-align: center;
            padding: 20px;
            color: var(--primary-color);
            font-style: italic;
        }
        
        .notification {
            position: fixed;
            top: 20px;
            left: 50%;
            transform: translateX(-50%);
            background: var(--accent-color);
            color: white;
            padding: 15px 30px;
            border-radius: 8px;
            box-shadow: var(--shadow);
            opacity: 0;
            transition: opacity 0.3s ease;
            z-index: 1000;
            display: flex;
            align-items: center;
            gap: 10px;
        }
        
        .notification.show {
            opacity: 1;
            animation: fadeInOut 2s forwards;
        }
        
        @keyframes fadeInOut {
            0% { opacity: 0; top: 10px; }
            20% { opacity: 1; top: 20px; }
            80% { opacity: 1; top: 20px; }
            100% { opacity: 0; top: 10px; }
        }
        
        footer {
            text-align: center;
            padding: 20px;
            color: #666;
            font-size: 0.9rem;
        }
        
        /* 响应式设计 - 移动设备优先 */
        @media (max-width: 768px) {
            body {
                padding: 15px;
            }
            
            header {
                padding: 20px 15px;
            }
            
            h1 {
                font-size: 1.8rem;
            }
            
            .subtitle {
                font-size: 0.95rem;
            }
            
            .dimension-selectors {
                gap: 15px;
            }
            
            .dimension-card {
                padding: 20px;
            }
            
            .dimension-title {
                font-size: 1.1rem;
            }
            
            .options-container {
                flex-direction: column;
            }
            
            .option-btn {
                width: 100%;
                padding: 10px;
            }
            
            .comment-section {
                padding: 20px;
            }
            
            .generate-btn {
                width: 100%;
                justify-content: center;
                margin-top: 5px;
            }
            
            .comment-header {
                flex-direction: column;
                align-items: stretch;
            }
        }
        
        @media (max-width: 480px) {
            h1 {
                font-size: 1.5rem;
            }
            
            .dimension-title {
                font-size: 1rem;
            }
            
            .dimension-title i {
                width: 35px;
                height: 35px;
                font-size: 1.2rem;
            }
            
            .comment-display {
                font-size: 1rem;
                padding: 15px;
            }
            
            .word-count {
                font-size: 0.85rem;
                padding: 6px 12px;
            }
            
            .word-count .highlight {
                font-size: 1rem;
            }
        }
        
        /* 加载动画 */
        .spinner {
            width: 24px;
            height: 24px;
            border: 3px solid rgba(255, 255, 255, 0.3);
            border-radius: 50%;
            border-top-color: white;
            animation: spin 1s linear infinite;
            display: inline-block;
            margin-right: 10px;
        }
        
        @keyframes spin {
            to { transform: rotate(360deg); }
        }
        
        /* 波纹效果 */
        .ripple {
            position: relative;
            overflow: hidden;
        }
        
        .ripple:after {
            content: "";
            display: block;
            position: absolute;
            width: 100%;
            height: 100%;
            top: 0;
            left: 0;
            pointer-events: none;
            background-image: radial-gradient(circle, #fff 10%, transparent 10.01%);
            background-repeat: no-repeat;
            background-position: 50%;
            transform: scale(10, 10);
            opacity: 0;
            transition: transform .5s, opacity 1s;
        }
        
        .ripple:active:after {
            transform: scale(0, 0);
            opacity: .3;
            transition: 0s;
        }
        
        /* 评语卡片动画 */
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(20px); }
            to { opacity: 1; transform: translateY(0); }
        }
        
        .fade-in {
            animation: fadeIn 0.5s ease-out;
        }
    </style>
</head>
<body>
    <div class="container">
        <header>
            <h1><i class="fas fa-chalkboard-teacher"></i> 小学教师智能评语生成系统</h1>
            <p class="subtitle">根据学生不同维度的表现，一键生成个性化、符合教育规范的期末评语</p>
        </header>
        
        <main>
            <div class="dimension-selectors">
                <!-- 学科成绩维度 -->
                <div class="dimension-card">
                    <h2 class="dimension-title">
                        <i class="fas fa-book"></i> 学科成绩
                    </h2>
                    <div class="options-container">
                        <button class="option-btn ripple" data-dimension="grade" data-value="优秀" aria-label="选择成绩优秀">
                            <i class="fas fa-star"></i> 优秀
                        </button>
                        <button class="option-btn ripple" data-dimension="grade" data-value="良好" aria-label="选择成绩良好">
                            <i class="fas fa-thumbs-up"></i> 良好
                        </button>
                        <button class="option-btn ripple" data-dimension="grade" data-value="合格" aria-label="选择成绩合格">
                            <i class="fas fa-check-circle"></i> 合格
                        </button>
                        <button class="option-btn ripple" data-dimension="grade" data-value="待提高" aria-label="选择成绩待提高">
                            <i class="fas fa-exclamation-triangle"></i> 待提高
                        </button>
                    </div>
                </div>
                
                <!-- 性格特质维度 -->
                <div class="dimension-card">
                    <h2 class="dimension-title">
                        <i class="fas fa-user-friends"></i> 性格特质
                    </h2>
                    <div class="options-container">
                        <button class="option-btn ripple" data-dimension="character" data-value="外向" aria-label="选择性格外向">
                            <i class="fas fa-comments"></i> 外向
                        </button>
                        <button class="option-btn ripple" data-dimension="character" data-value="内向" aria-label="选择性格内向">
                            <i class="fas fa-book-reader"></i> 内向
                        </button>
                        <button class="option-btn ripple" data-dimension="character" data-value="开朗" aria-label="选择性格开朗">
                            <i class="fas fa-laugh-beam"></i> 开朗
                        </button>
                        <button class="option-btn ripple" data-dimension="character" data-value="稳重" aria-label="选择性格稳重">
                            <i class="fas fa-brain"></i> 稳重
                        </button>
                    </div>
                </div>
                
                <!-- 课堂表现维度 -->
                <div class="dimension-card">
                    <h2 class="dimension-title">
                        <i class="fas fa-chalkboard"></i> 课堂表现
                    </h2>
                    <div class="options-container">
                        <button class="option-btn ripple" data-dimension="performance" data-value="积极" aria-label="选择课堂表现积极">
                            <i class="fas fa-hand-paper"></i> 积极
                        </button>
                        <button class="option-btn ripple" data-dimension="performance" data-value="专注" aria-label="选择课堂表现专注">
                            <i class="fas fa-eye"></i> 专注
                        </button>
                        <button class="option-btn ripple" data-dimension="performance" data-value="需提升" aria-label="选择课堂表现需提升">
                            <i class="fas fa-chart-line"></i> 需提升
                        </button>
                    </div>
                </div>
            </div>
            
            <div class="comment-section">
                <div class="comment-header">
                    <div class="word-count">
                        <i class="fas fa-font"></i> 字数统计: 
                        <span class="highlight">0</span> 字 (目标: 50-60字)
                    </div>
                    <button class="generate-btn ripple" id="generateBtn" aria-label="生成评语">
                        <span class="spinner" id="spinner" style="display:none;"></span>
                        <i class="fas fa-magic"></i> 生成评语
                    </button>
                </div>
                
                <div class="comment-display" id="commentDisplay" tabindex="0" aria-label="生成的评语内容">
                    <div class="placeholder-text">请选择学生各维度表现，然后点击"生成评语"按钮</div>
                </div>
                
                <div class="copy-section">
                    <button class="copy-btn ripple" id="copyBtn" aria-label="复制评语到剪贴板">
                        <i class="fas fa-copy"></i> 复制评语
                    </button>
                </div>
            </div>
        </main>
        
        <div class="notification" id="notification">
            <i class="fas fa-check-circle"></i> 评语已成功复制到剪贴板！
        </div>
        
        <footer>
            <p>小学教师智能评语生成系统 © 2023 | 让期末评语撰写更高效、更科学</p>
        </footer>
    </div>

    <script>
        // 评语模板库 - 存储为JSON格式，方便教师自定义扩展
        const commentTemplates = {
            // 完全匹配的模板
            exactMatches: [
                {
                    grade: "优秀",
                    character: "外向",
                    performance: "积极",
                    content: "该生成绩优秀，性格活泼外向，课堂上积极发言参与互动。继续保持学习热情，同时注意培养更深入的思考能力。"
                },
                {
                    grade: "优秀",
                    character: "稳重",
                    performance: "专注",
                    content: "该生成绩优秀，性格稳重踏实，课堂上专注认真听讲。建议在保持优势的同时，多参与课堂讨论，锻炼表达能力。"
                },
                {
                    grade: "良好",
                    character: "开朗",
                    performance: "积极",
                    content: "该生成绩良好，性格开朗阳光，课堂上积极参与各项活动。建议加强基础知识的巩固练习，进一步提升学习效果。"
                },
                {
                    grade: "良好",
                    character: "内向",
                    performance: "专注",
                    content: "该生成绩良好，性格文静内向，课堂上能专注听讲。建议多与同学交流合作，增强自信心和表达能力。"
                },
                {
                    grade: "合格",
                    character: "外向",
                    performance: "需提升",
                    content: "该生成绩合格，性格活泼外向，但课堂上注意力有时分散。建议加强自律能力培养，提高课堂学习效率。"
                },
                {
                    grade: "待提高",
                    character: "内向",
                    performance: "需提升",
                    content: "该生学习有待提高，性格内向安静，课堂上参与度不足。建议加强基础知识学习，多请教老师和同学。"
                }
            ],
            
            // 基础模板 + 维度特征词组合
            baseTemplates: [
                "{name}在本学期{gradeStatement}，{characterStatement}，{performanceStatement}。{suggestion}",
                "这学期{name}{gradeStatement}，{characterStatement}，{performanceStatement}。{suggestion}",
                "{name}同学{gradeStatement}，{characterStatement}，{performanceStatement}。{suggestion}"
            ],
            
            // 维度特征词库
            gradeStatements: {
                "优秀": "成绩优秀，展现了扎实的知识基础",
                "良好": "取得了良好的学习成绩",
                "合格": "学习成绩基本合格",
                "待提高": "学习成绩有待提高"
            },
            
            characterStatements: {
                "外向": "性格外向开朗，善于与同学交流",
                "内向": "性格文静内向，做事认真细致",
                "开朗": "性格活泼开朗，深受同学喜爱",
                "稳重": "性格稳重踏实，做事有条理"
            },
            
            performanceStatements: {
                "积极": "课堂上表现积极，踊跃发言",
                "专注": "课堂上专注认真，学习态度端正",
                "需提升": "课堂表现需进一步提升"
            },
            
            // 发展建议库
            suggestions: {
                "优秀": "希望继续保持优势，挑战更高目标！",
                "良好": "继续努力，争取更大进步！",
                "合格": "多加练习，夯实基础，争取更好成绩！",
                "待提高": "请加强基础知识学习，及时查漏补缺！"
            }
        };
        
        // 学生姓名占位符
        const STUDENT_NAME_PLACEHOLDER = "{name}";
        
        // 当前选择的维度值
        let currentSelection = {
            grade: "优秀",
            character: "开朗",
            performance: "积极"
        };
        
        // DOM元素
        const gradeOptions = document.querySelectorAll('[data-dimension="grade"]');
        const characterOptions = document.querySelectorAll('[data-dimension="character"]');
        const performanceOptions = document.querySelectorAll('[data-dimension="performance"]');
        const generateBtn = document.getElementById('generateBtn');
        const copyBtn = document.getElementById('copyBtn');
        const commentDisplay = document.getElementById('commentDisplay');
        const wordCountElement = document.querySelector('.word-count .highlight');
        const spinner = document.getElementById('spinner');
        const notification = document.getElementById('notification');
        
        // 初始化页面
        function initPage() {
            // 设置默认选项
            setSelectedOption('grade', currentSelection.grade);
            setSelectedOption('character', currentSelection.character);
            setSelectedOption('performance', currentSelection.performance);
            
            // 生成初始评语
            generateComment();
            
            // 添加事件监听器
            addEventListeners();
        }
        
        // 设置选中的选项
        function setSelectedOption(dimension, value) {
            const options = document.querySelectorAll(`[data-dimension="${dimension}"]`);
            options.forEach(option => {
                if (option.dataset.value === value) {
                    option.classList.add('selected');
                } else {
                    option.classList.remove('selected');
                }
            });
        }
        
        // 添加事件监听器
        function addEventListeners() {
            // 维度选择
            gradeOptions.forEach(option => {
                option.addEventListener('click', () => updateSelection('grade', option.dataset.value));
            });
            
            characterOptions.forEach(option => {
                option.addEventListener('click', () => updateSelection('character', option.dataset.value));
            });
            
            performanceOptions.forEach(option => {
                option.addEventListener('click', () => updateSelection('performance', option.dataset.value));
            });
            
            // 生成评语按钮
            generateBtn.addEventListener('click', generateComment);
            
            // 复制按钮
            copyBtn.addEventListener('click', copyComment);
            
            // 键盘快捷键支持
            document.addEventListener('keydown', (e) => {
                if (e.key === 'Enter' && !e.shiftKey) {
                    e.preventDefault();
                    generateComment();
                }
            });
        }
        
        // 更新选择
        function updateSelection(dimension, value) {
            currentSelection[dimension] = value;
            setSelectedOption(dimension, value);
        }
        
        // 生成评语
        function generateComment() {
            // 显示加载状态
            showLoading();
            
            // 延迟生成，模拟思考过程
            setTimeout(() => {
                let comment;
                
                // 1. 尝试寻找完全匹配的模板
                const exactMatch = commentTemplates.exactMatches.find(template => 
                    template.grade === currentSelection.grade &&
                    template.character === currentSelection.character &&
                    template.performance === currentSelection.performance
                );
                
                if (exactMatch) {
                    comment = exactMatch.content;
                } else {
                    // 2. 使用基础模板 + 维度特征词组合
                    const randomTemplate = commentTemplates.baseTemplates[Math.floor(Math.random() * commentTemplates.baseTemplates.length)];
                    
                    // 替换占位符
                    comment = randomTemplate
                        .replace("{gradeStatement}", commentTemplates.gradeStatements[currentSelection.grade])
                        .replace("{characterStatement}", commentTemplates.characterStatements[currentSelection.character])
                        .replace("{performanceStatement}", commentTemplates.performanceStatements[currentSelection.performance])
                        .replace("{suggestion}", commentTemplates.suggestions[currentSelection.grade])
                        .replace(/{name}/g, "该生");
                }
                
                // 显示评语
                displayComment(comment);
                
                // 隐藏加载状态
                hideLoading();
                
                // 滚动到评语区域
                commentDisplay.scrollIntoView({ behavior: 'smooth', block: 'center' });
            }, 600); // 模拟生成延迟
        }
        
        // 显示加载状态
        function showLoading() {
            spinner.style.display = 'inline-block';
            generateBtn.disabled = true;
        }
        
        // 隐藏加载状态
        function hideLoading() {
            spinner.style.display = 'none';
            generateBtn.disabled = false;
        }
        
        // 显示评语
        function displayComment(comment) {
            commentDisplay.classList.remove('fade-in');
            // 强制重排以重新触发动画
            void commentDisplay.offsetWidth;
            
            commentDisplay.innerHTML = `<p>${comment}</p>`;
            commentDisplay.classList.add('fade-in');
            updateWordCount(comment);
        }
        
        // 更新字数统计
        function updateWordCount(comment) {
            // 计算中文字符数（每个汉字、标点算一个字）
            const chineseCharCount = comment.replace(/[^\u4e00-\u9fa5]/g, '').length;
            wordCountElement.textContent = chineseCharCount;
            
            // 根据字数调整颜色
            if (chineseCharCount >= 50 && chineseCharCount <= 60) {
                wordCountElement.style.color = '#4CAF50'; // 绿色
            } else {
                wordCountElement.style.color = '#F44336'; // 红色
            }
        }
        
        // 复制评语
        function copyComment() {
            const commentText = commentDisplay.innerText;
            
            if (!commentText || commentText.includes("请选择学生各维度表现")) return;
            
            navigator.clipboard.writeText(commentText).then(() => {
                showNotification();
                copyBtn.classList.add('copied');
                setTimeout(() => copyBtn.classList.remove('copied'), 2000);
            }).catch(err => {
                console.error('复制失败:', err);
                alert('复制失败，请手动复制评语内容');
            });
        }
        
        // 显示通知
        function showNotification() {
            notification.classList.add('show');
            setTimeout(() => {
                notification.classList.remove('show');
            }, 2000);
        }
        
        // 页面加载完成后初始化
        window.addEventListener('DOMContentLoaded', initPage);
    </script>
</body>
</html>